package com.itbaizhan.controller;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.itbaizhan.domain.Product;
import com.itbaizhan.dto.ProductDto;
import com.itbaizhan.service.ProductService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.ModelAndView;

/**
 * @author spf
 * @date 2024/5/6
 * @time 20:57
 */
@Controller
@RequestMapping("/shopping")
public class ProductController {

    @Autowired
    private ProductService productService;

    @GetMapping("/product")
    public ModelAndView findProductPage(ProductDto productDto){
        Page<Product> products = productService.findProduct(productDto);
        ModelAndView modelAndView = new ModelAndView();
        modelAndView.setViewName("product");
        modelAndView.addObject("products", products);
        return modelAndView;
    }

}
